package com.czxy.home.web.servlet;

import cn.itcast.servlet.BaseServlet;
import com.czxy.home.utils.TestEmail;

import java.io.IOException;

/**
 * @author xuhongzu
 * @version 1.0
 * @date 2019/4/24
 */
public class LoginServlet extends BaseServlet {
    /**
     * 发送邮箱验证码
     * @return
     */
    public String emailVc() {
        String email = getRequest().getParameter("email");
        System.out.println(email);
        try {
            String trueEmail = TestEmail.sendEmail(email);
            //将发送的邮箱验证码存入session
            getRequest().getSession().setAttribute("trueEmail",trueEmail);
            getResponse().getWriter().write("邮箱验证码发送成功");
        } catch (Exception e) {
            try {
                getResponse().getWriter().write("邮箱输入不正确");
            } catch (IOException ex) {
                System.out.println("出现错误");
            }
        }
        return null;
    }
}
